unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Btnx_1: TButton;
    Btnx_2: TButton;
    procedure Btnx_1Click(Sender: TObject);
    procedure Btnx_2Click(Sender: TObject);
  private
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Btnx_1Click(Sender: TObject);
var
  I,M:Integer;
  SourceList:TStringList;
  TargetList:TStringList;
begin
  SourceList:=TStringList.Create;
  TargetList:=TStringList.Create;

  SourceList.Delimiter:=',';
  SourceList.DelimitedText:=Edit1.Text;

  TargetList.Delimiter:=',';
  TargetList.DelimitedText:=Edit2.Text;

  for I:=SourceList.Count-1 downto 0 do
  begin
    M:=-1;
    M:=TargetList.IndexOf(SourceList.Strings[I]);
    if M=-1 then Continue;

    SourceList.Delete(I);
    TargetList.Delete(M);
  end;

  ShowMessage(SourceList.Text+#13+TargetList.Text);

  
end;

procedure TForm1.Btnx_2Click(Sender: TObject);
begin
  ModalResult:=mrCancel;
end;

end.
